package com.xwtec.proxy.v3;

import java.util.Random;

/**
 * @Author: zt
 * @Date: 2021/3/2 22:01
 *
 * 利用聚合
 */
public class Tank implements Movable{
    @Override
    public void move() {

        System.out.println("Tank Move claclacla.....");
        try {
            Thread.sleep(new Random().nextInt(4000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }
}
interface Movable{
    void move();
}

class TankTimeProxy implements Movable{
    Tank tank ;

    public TankTimeProxy(Tank tank) {
        this.tank = tank;
    }

    @Override
    public void move() {
        long start  = System.currentTimeMillis();
        tank.move();
        long end = System.currentTimeMillis();
        System.out.println(end-start);

    }

    public static void main(String[] args) {
        new TankTimeProxy(new Tank()).move();
    }
}